using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;
using System.Data;
using Sinacor.Infra.Service.Data;
using Sinacor.Infra.Service.Security.Authorization;
using Sinacor.Infra.Service.Common;

namespace Sinacor.Servico.Bovespa.Corretagem.ResourceAccess
{

    /// <summary>
    /// Business Logic BaseCalculo
    /// </summary>
    public class BaseCalculo : BaseResourceAccess
    {
        #region Construtor

        /// <summary>
        /// Construtor padrão
        /// </summary>
        public BaseCalculo()
            : base()
        {
        }

        #endregion
        
        #region ConsultarBaseCalculo
        /// <summary>
        /// Método ConsultarBaseCalculo
        /// </summary>
        public List<BusinessEntity.BaseCalculo> ConsultarBaseCalculo()
        {
            List<BusinessEntity.BaseCalculo> response = null;
            StringBuilder sql = new StringBuilder();

            sql.Append(@"SELECT IN_BASE_CALC, DESC_TIPO_APLC_CORT, COD_TIPO_BASE_CALC
							FROM  TBOTIPO_APLC_CORT");

            using (DbCommand command = this.DataBase.GetSqlStringCommand(sql.ToString()))
            {

                response = this.FindAll<BusinessEntity.BaseCalculo>(command, new ConstructEntity<BusinessEntity.BaseCalculo>(ConstrutorConsultarBaseCalculo));
            }

            return response;
        }

        #endregion

        #region ConstrutorConsultarBaseCalculo
        protected BusinessEntity.BaseCalculo ConstrutorConsultarBaseCalculo(IDataReader reader)
        {
            BusinessEntity.BaseCalculo entity = new BusinessEntity.BaseCalculo();

            entity.TipoBaseCalculo = EnumConverter.Parse<Sinacor.Servico.Bovespa.Corretagem.BusinessEntity.Enum.TipoBaseCalculo>(reader.GetValue<string>("COD_TIPO_BASE_CALC"));
            entity.Descricao = reader.GetValue<System.String>("DESC_TIPO_APLC_CORT");
            entity.Codigo = reader.GetValue<System.String>("IN_BASE_CALC");

            return entity;
        }
        #endregion

    }
}



